package cn.rubintry.flowbus

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import cn.rubintry.flow.bus.FlowBus
import cn.rubintry.flow.bus.annotation.Bus

class MainActivity : AppCompatActivity() {
    private var count = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        FlowBus.getDefault().register(this)
        FlowBus.getDefault().post("tagggggggg" , "1231233123")
    }


    @Bus(tag = "tagggggggg")
    fun test(result: String){
        println("result : ${result}")
    }

    @Bus(tag = "tag")
    fun test2(startTime: Long){
        count ++
        val curDelay = System.currentTimeMillis() - startTime
        println("事件总数: ${count}  当前耗时 : ${curDelay}  平均耗时：${curDelay / count.toFloat()}毫秒")
    }

    fun goToSecond(view: View) {
        startActivity(Intent(this , SecondActivity::class.java))
    }
}